//package com.tinywind.Sword.Controller;
//
//import java.util.List;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.tinywind.Sword.Entity.TodoEntity;
//import com.tinywind.Sword.Entity.VisitorEntity;
//import com.tinywind.Sword.Service.VisitorService;
//import com.tinywind.Sword.Utility.GajsvTimeManager;
//import com.tinywind.Sword.dto.Result;
//
//@RestController
//@CrossOrigin
//@RequestMapping("/Visitor") // url:/模块/资源/{id}/细分 /seckill/list
//public class VisitorController {
//		private Logger logger = LoggerFactory.getLogger(this.getClass());
//	
//		@Autowired
//		private VisitorService service;
//	
//		@RequestMapping(produces = "application/json; charset=utf-8",value = "/List", method = RequestMethod.POST)
//		private Result list(Model model) {
//			try {
//				List<VisitorEntity> list = service.getList();
//				return new Result(0,list);
//			} catch (Exception e) {
//				System.out.format("TodoController/list exception,%s",e.getMessage());
//				e.printStackTrace();
//				return new Result(-1);
//			}
//		}
//	
//		@RequestMapping(produces = "application/json; charset=utf-8",value = "/Search", method = RequestMethod.POST)
//		@ResponseBody
//		public Result search(int id) {
//			try {
//				VisitorEntity entity = service.search(id);
//				logger.debug("VisitorController/search success, id is %d",id);
//				return new Result(0,entity);
//			}
//			catch (Exception e) {
//				logger.debug("VisitorController/search exception,%s",e.getMessage());
//				e.printStackTrace();
//				return new Result(-1);
//			}
//		}
//	
//		@RequestMapping(produces = "application/json; charset=utf-8",value = "/Delete", method = RequestMethod.POST)
//		public Result delete(Long id) {
//			System.out.format("\n\n\n\nTodo id is %d\n\n\n", id);
//			try {
//				service.delete(id.intValue());
//			} catch (Exception e) {
//				System.out.format("\n\n\n\n delete error!!! \n\n\n");
//				e.printStackTrace();
//			}
//			return new Result(0);
//		}
//	
//		
//		@RequestMapping(produces = "application/json; charset=utf-8",value = "/Insert", method = RequestMethod.POST)
//		public Result insert(String phone, String weixin,Integer status,String name) {
//			VisitorEntity entity = new VisitorEntity();
//			entity.phone = phone;
//			entity.weixin = weixin;
//			entity.name = name;
//			entity.isDelete = false;
//			if(status == null) {
//				status = 0;
//			}
//			entity.status = status;
//			String now = GajsvTimeManager.sharedInstance.stdTimeStringForNow();
//			entity.createTime = now;
//			entity.updateTime = now;
//			try {
//				// 返回值是一个bool值,应该是返回影响的条数.新增的id直接在entity中.
//				int id = service.insert(entity);
//				logger.debug("VisitorController/Insert success, id is %d",id);
//				return new Result(0, entity);
//			} catch (Exception e) {
//				logger.debug("VisitorController/Insert exception,%s",e.getMessage());
//				e.printStackTrace();
//				return new Result(-1);
//			}
//		}
//		
//		@RequestMapping(produces = "application/json; charset=utf-8",value = "/Update", method = RequestMethod.POST)
//		public Result update(int id,String name, String phone, String weixin,Integer status,Boolean isDelete) {
//			VisitorEntity entity = service.search(id);
//			
//			//先查找,然后有值的修改,没有值的不改.
//			if(name != null) {
//				entity.name = name;
//			}
//			if(phone != null) {
//				entity.phone = phone;
//			}
//			if(weixin != null) {
//				entity.weixin = weixin;
//			}
//			
//			if(isDelete != null) {
//				entity.isDelete = isDelete;
//			}
//			if(status != null) {
//				entity.status = status;
//			}
//			
//			String now = GajsvTimeManager.sharedInstance.stdTimeStringForNow();
//			entity.updateTime = now;
//			
//			try {
//				// 返回值是一个bool值,应该是返回影响的条数.新增的id直接在entity中.
//				service.update(entity);
//				logger.debug("VisitorController/Update success, id is %d",id);
//				return new Result(0, entity);
//			} catch (Exception e) {
//				logger.debug("VisitorController/Update exception,%s",e.getMessage());
//				e.printStackTrace();
//				return new Result(-1);
//			}
//		}
//	
//	}